{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "initial_id",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-03-14T13:30:44.471033800Z",
     "start_time": "2024-03-14T13:30:44.425966500Z"
    },
    "collapsed": true,
    "jupyter": {
     "outputs_hidden": true
    }
   },
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import matplotlib.pyplot as plt\n",
    "import seaborn as sns\n",
    "import warnings\n",
    "import numpy as np\n",
    "from datetime import datetime\n",
    "from sklearn.preprocessing import LabelEncoder\n",
    "from collections import Counter\n",
    "\n",
    "#设置为seaborn风格\n",
    "sns.set()\n",
    "#不显示警告\n",
    "warnings.filterwarnings(\"ignore\")\n",
    "plt.rcParams['font.sans-serif'] = ['SimHei']  #显示中文\n",
    "plt.rcParams['axes.unicode_minus'] = False  #用来正常显示负号"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "1d0fa6d0e16df939",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-03-14T13:31:08.038538200Z",
     "start_time": "2024-03-14T13:30:44.472038600Z"
    },
    "collapsed": false,
    "jupyter": {
     "outputs_hidden": false
    }
   },
   "outputs": [],
   "source": [
    "clor = pd.read_csv('./CL_OR.csv')\n",
    "users = pd.read_csv('./user_expand.csv')\n",
    "skus = pd.read_csv('./sku_expand.csv')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c33592ea0f8d35a7",
   "metadata": {
    "collapsed": false,
    "jupyter": {
     "outputs_hidden": false
    }
   },
   "source": [
    "商品基本特征\n",
    "- a1，a2进行独热编码\n",
    "- 类别和品牌直接作为特征"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "672ec5df793e8da5",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-03-14T13:31:08.077086700Z",
     "start_time": "2024-03-14T13:31:08.041040700Z"
    },
    "collapsed": false,
    "jupyter": {
     "outputs_hidden": false
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "sku_ID               a234e08c57\n",
       "type                          1\n",
       "brand_ID             c3ab4bf4d9\n",
       "attribute1                  3.0\n",
       "attribute2                 60.0\n",
       "activate_date               NaN\n",
       "deactivate_date             NaN\n",
       "is_click                    644\n",
       "is_order                     74\n",
       "order_click_ratio      0.114907\n",
       "Name: 0, dtype: object"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "skus.iloc[0]"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7c8f0edbf5d546f7",
   "metadata": {
    "collapsed": false,
    "jupyter": {
     "outputs_hidden": false
    }
   },
   "source": [
    "用户特征： "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "5580071ac22d44e8",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-03-14T13:31:08.092353200Z",
     "start_time": "2024-03-14T13:31:08.070155500Z"
    },
    "collapsed": false,
    "jupyter": {
     "outputs_hidden": false
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "user_ID              000089d6a6\n",
       "user_level                    1\n",
       "first_order_month       2017-08\n",
       "plus                          0\n",
       "gender                        F\n",
       "age                           3\n",
       "marital_status                S\n",
       "education                     3\n",
       "city_level                    4\n",
       "purchase_power                3\n",
       "is_click                   10.0\n",
       "is_order                    8.0\n",
       "order_click_ratio           0.8\n",
       "Name: 0, dtype: object"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "users.iloc[0]"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4290a1afab287af4",
   "metadata": {
    "collapsed": false,
    "jupyter": {
     "outputs_hidden": false
    }
   },
   "source": [
    "行为特征"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "53723bcf8e201b10",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-03-14T13:31:08.110108300Z",
     "start_time": "2024-03-14T13:31:08.085111100Z"
    },
    "collapsed": false,
    "jupyter": {
     "outputs_hidden": false
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Unnamed: 0                                      0\n",
       "sku_ID                                 a234e08c57\n",
       "user_ID                                4c3d6d10c2\n",
       "request_time                  2018-03-01 23:57:53\n",
       "channel                                    wechat\n",
       "order_ID                                      NaN\n",
       "order_date                                    NaN\n",
       "order_time                                    NaN\n",
       "quantity                                      NaN\n",
       "type                                          NaN\n",
       "promise                                       NaN\n",
       "original_unit_price                           NaN\n",
       "final_unit_price                              NaN\n",
       "direct_discount_per_unit                      NaN\n",
       "quantity_discount_per_unit                    NaN\n",
       "bundle_discount_per_unit                      NaN\n",
       "coupon_discount_per_unit                      NaN\n",
       "gift_item                                     NaN\n",
       "dc_ori                                        NaN\n",
       "dc_des                                        NaN\n",
       "click_week                                      4\n",
       "click_hour                                     23\n",
       "order_week                                    NaN\n",
       "order_hour                                    NaN\n",
       "click_day                                       1\n",
       "order_day                                     NaN\n",
       "Name: 0, dtype: object"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "clor.iloc[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "1547fc396a85db76",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-03-14T13:31:08.138032Z",
     "start_time": "2024-03-14T13:31:08.101087500Z"
    },
    "collapsed": false,
    "jupyter": {
     "outputs_hidden": false
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "RangeIndex: 20321457 entries, 0 to 20321456\n",
      "Data columns (total 26 columns):\n",
      " #   Column                      Dtype  \n",
      "---  ------                      -----  \n",
      " 0   Unnamed: 0                  int64  \n",
      " 1   sku_ID                      object \n",
      " 2   user_ID                     object \n",
      " 3   request_time                object \n",
      " 4   channel                     object \n",
      " 5   order_ID                    object \n",
      " 6   order_date                  object \n",
      " 7   order_time                  object \n",
      " 8   quantity                    float64\n",
      " 9   type                        float64\n",
      " 10  promise                     object \n",
      " 11  original_unit_price         float64\n",
      " 12  final_unit_price            float64\n",
      " 13  direct_discount_per_unit    float64\n",
      " 14  quantity_discount_per_unit  float64\n",
      " 15  bundle_discount_per_unit    float64\n",
      " 16  coupon_discount_per_unit    float64\n",
      " 17  gift_item                   float64\n",
      " 18  dc_ori                      float64\n",
      " 19  dc_des                      float64\n",
      " 20  click_week                  int64  \n",
      " 21  click_hour                  int64  \n",
      " 22  order_week                  float64\n",
      " 23  order_hour                  float64\n",
      " 24  click_day                   int64  \n",
      " 25  order_day                   float64\n",
      "dtypes: float64(14), int64(4), object(8)\n",
      "memory usage: 3.9+ GB\n"
     ]
    }
   ],
   "source": [
    "clor.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "89f1e6d1fd2d196d",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-03-14T13:32:59.402400400Z",
     "start_time": "2024-03-14T13:32:54.756104700Z"
    },
    "collapsed": false,
    "jupyter": {
     "outputs_hidden": false
    }
   },
   "outputs": [],
   "source": [
    "clor[['quantity', 'type',\n",
    "      'original_unit_price', 'final_unit_price', 'direct_discount_per_unit',\n",
    "      'quantity_discount_per_unit', 'bundle_discount_per_unit',\n",
    "      'coupon_discount_per_unit', 'gift_item', 'dc_ori', 'dc_des', 'click_week', 'click_hour', 'order_week',\n",
    "      'order_hour',\n",
    "      'click_day', 'order_day']] \\\n",
    "    = clor[['quantity', 'type',\n",
    "            'original_unit_price', 'final_unit_price', 'direct_discount_per_unit',\n",
    "            'quantity_discount_per_unit', 'bundle_discount_per_unit',\n",
    "            'coupon_discount_per_unit', 'gift_item', 'dc_ori', 'dc_des', 'click_week', 'click_hour', 'order_week',\n",
    "            'order_hour',\n",
    "            'click_day', 'order_day']].astype('float32')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "40a501a0cee0f8ec",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-03-14T13:33:01.983391800Z",
     "start_time": "2024-03-14T13:33:01.966856600Z"
    },
    "collapsed": false,
    "jupyter": {
     "outputs_hidden": false
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "RangeIndex: 20321457 entries, 0 to 20321456\n",
      "Data columns (total 26 columns):\n",
      " #   Column                      Dtype  \n",
      "---  ------                      -----  \n",
      " 0   Unnamed: 0                  int64  \n",
      " 1   sku_ID                      object \n",
      " 2   user_ID                     object \n",
      " 3   request_time                object \n",
      " 4   channel                     object \n",
      " 5   order_ID                    object \n",
      " 6   order_date                  object \n",
      " 7   order_time                  object \n",
      " 8   quantity                    float32\n",
      " 9   type                        float32\n",
      " 10  promise                     object \n",
      " 11  original_unit_price         float32\n",
      " 12  final_unit_price            float32\n",
      " 13  direct_discount_per_unit    float32\n",
      " 14  quantity_discount_per_unit  float32\n",
      " 15  bundle_discount_per_unit    float32\n",
      " 16  coupon_discount_per_unit    float32\n",
      " 17  gift_item                   float32\n",
      " 18  dc_ori                      float32\n",
      " 19  dc_des                      float32\n",
      " 20  click_week                  float32\n",
      " 21  click_hour                  float32\n",
      " 22  order_week                  float32\n",
      " 23  order_hour                  float32\n",
      " 24  click_day                   float32\n",
      " 25  order_day                   float32\n",
      "dtypes: float32(17), int64(1), object(8)\n",
      "memory usage: 2.6+ GB\n"
     ]
    }
   ],
   "source": [
    "clor.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "15b547d2df3ce2e2",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-03-14T13:33:19.240252400Z",
     "start_time": "2024-03-14T13:33:19.225048400Z"
    },
    "collapsed": false,
    "jupyter": {
     "outputs_hidden": false
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Unnamed: 0</th>\n",
       "      <th>sku_ID</th>\n",
       "      <th>user_ID</th>\n",
       "      <th>request_time</th>\n",
       "      <th>channel</th>\n",
       "      <th>order_ID</th>\n",
       "      <th>order_date</th>\n",
       "      <th>order_time</th>\n",
       "      <th>quantity</th>\n",
       "      <th>type</th>\n",
       "      <th>...</th>\n",
       "      <th>coupon_discount_per_unit</th>\n",
       "      <th>gift_item</th>\n",
       "      <th>dc_ori</th>\n",
       "      <th>dc_des</th>\n",
       "      <th>click_week</th>\n",
       "      <th>click_hour</th>\n",
       "      <th>order_week</th>\n",
       "      <th>order_hour</th>\n",
       "      <th>click_day</th>\n",
       "      <th>order_day</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0</td>\n",
       "      <td>a234e08c57</td>\n",
       "      <td>4c3d6d10c2</td>\n",
       "      <td>2018-03-01 23:57:53</td>\n",
       "      <td>wechat</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>4.0</td>\n",
       "      <td>23.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1.0</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1</td>\n",
       "      <td>6449e1fd87</td>\n",
       "      <td>-</td>\n",
       "      <td>2018-03-01 16:13:48</td>\n",
       "      <td>wechat</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>4.0</td>\n",
       "      <td>16.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1.0</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2</td>\n",
       "      <td>09b70fcd83</td>\n",
       "      <td>2791ec4485</td>\n",
       "      <td>2018-03-01 22:10:51</td>\n",
       "      <td>wechat</td>\n",
       "      <td>e4874e2a00</td>\n",
       "      <td>2018-03-01</td>\n",
       "      <td>2018-03-01 14:08:33</td>\n",
       "      <td>1.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>...</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>24.0</td>\n",
       "      <td>40.0</td>\n",
       "      <td>4.0</td>\n",
       "      <td>22.0</td>\n",
       "      <td>4.0</td>\n",
       "      <td>14.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>3</td>\n",
       "      <td>09b70fcd83</td>\n",
       "      <td>eb0718c1c9</td>\n",
       "      <td>2018-03-01 16:34:08</td>\n",
       "      <td>wechat</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>4.0</td>\n",
       "      <td>16.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1.0</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>4</td>\n",
       "      <td>09b70fcd83</td>\n",
       "      <td>59f84cf342</td>\n",
       "      <td>2018-03-01 22:20:35</td>\n",
       "      <td>wechat</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>4.0</td>\n",
       "      <td>22.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1.0</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 26 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "   Unnamed: 0      sku_ID     user_ID         request_time channel  \\\n",
       "0           0  a234e08c57  4c3d6d10c2  2018-03-01 23:57:53  wechat   \n",
       "1           1  6449e1fd87           -  2018-03-01 16:13:48  wechat   \n",
       "2           2  09b70fcd83  2791ec4485  2018-03-01 22:10:51  wechat   \n",
       "3           3  09b70fcd83  eb0718c1c9  2018-03-01 16:34:08  wechat   \n",
       "4           4  09b70fcd83  59f84cf342  2018-03-01 22:20:35  wechat   \n",
       "\n",
       "     order_ID  order_date           order_time  quantity  type  ...  \\\n",
       "0         NaN         NaN                  NaN       NaN   NaN  ...   \n",
       "1         NaN         NaN                  NaN       NaN   NaN  ...   \n",
       "2  e4874e2a00  2018-03-01  2018-03-01 14:08:33       1.0   2.0  ...   \n",
       "3         NaN         NaN                  NaN       NaN   NaN  ...   \n",
       "4         NaN         NaN                  NaN       NaN   NaN  ...   \n",
       "\n",
       "  coupon_discount_per_unit  gift_item  dc_ori  dc_des  click_week  click_hour  \\\n",
       "0                      NaN        NaN     NaN     NaN         4.0        23.0   \n",
       "1                      NaN        NaN     NaN     NaN         4.0        16.0   \n",
       "2                      0.0        0.0    24.0    40.0         4.0        22.0   \n",
       "3                      NaN        NaN     NaN     NaN         4.0        16.0   \n",
       "4                      NaN        NaN     NaN     NaN         4.0        22.0   \n",
       "\n",
       "   order_week  order_hour  click_day  order_day  \n",
       "0         NaN         NaN        1.0        NaN  \n",
       "1         NaN         NaN        1.0        NaN  \n",
       "2         4.0        14.0        1.0        1.0  \n",
       "3         NaN         NaN        1.0        NaN  \n",
       "4         NaN         NaN        1.0        NaN  \n",
       "\n",
       "[5 rows x 26 columns]"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "clor.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "af510723a9e5a11c",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-03-14T13:39:21.583136600Z",
     "start_time": "2024-03-14T13:39:19.460472900Z"
    },
    "collapsed": false,
    "jupyter": {
     "outputs_hidden": false
    }
   },
   "outputs": [],
   "source": [
    "clor.drop(columns=['Unnamed: 0'], inplace=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "417f880eb482b49c",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-03-14T13:39:34.241313900Z",
     "start_time": "2024-03-14T13:39:34.216288700Z"
    },
    "collapsed": false,
    "jupyter": {
     "outputs_hidden": false
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>sku_ID</th>\n",
       "      <th>user_ID</th>\n",
       "      <th>request_time</th>\n",
       "      <th>channel</th>\n",
       "      <th>order_ID</th>\n",
       "      <th>order_date</th>\n",
       "      <th>order_time</th>\n",
       "      <th>quantity</th>\n",
       "      <th>type</th>\n",
       "      <th>promise</th>\n",
       "      <th>...</th>\n",
       "      <th>coupon_discount_per_unit</th>\n",
       "      <th>gift_item</th>\n",
       "      <th>dc_ori</th>\n",
       "      <th>dc_des</th>\n",
       "      <th>click_week</th>\n",
       "      <th>click_hour</th>\n",
       "      <th>order_week</th>\n",
       "      <th>order_hour</th>\n",
       "      <th>click_day</th>\n",
       "      <th>order_day</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>a234e08c57</td>\n",
       "      <td>4c3d6d10c2</td>\n",
       "      <td>2018-03-01 23:57:53</td>\n",
       "      <td>wechat</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>4.0</td>\n",
       "      <td>23.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1.0</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>6449e1fd87</td>\n",
       "      <td>-</td>\n",
       "      <td>2018-03-01 16:13:48</td>\n",
       "      <td>wechat</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>4.0</td>\n",
       "      <td>16.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1.0</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>09b70fcd83</td>\n",
       "      <td>2791ec4485</td>\n",
       "      <td>2018-03-01 22:10:51</td>\n",
       "      <td>wechat</td>\n",
       "      <td>e4874e2a00</td>\n",
       "      <td>2018-03-01</td>\n",
       "      <td>2018-03-01 14:08:33</td>\n",
       "      <td>1.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>-</td>\n",
       "      <td>...</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>24.0</td>\n",
       "      <td>40.0</td>\n",
       "      <td>4.0</td>\n",
       "      <td>22.0</td>\n",
       "      <td>4.0</td>\n",
       "      <td>14.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>09b70fcd83</td>\n",
       "      <td>eb0718c1c9</td>\n",
       "      <td>2018-03-01 16:34:08</td>\n",
       "      <td>wechat</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>4.0</td>\n",
       "      <td>16.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1.0</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>09b70fcd83</td>\n",
       "      <td>59f84cf342</td>\n",
       "      <td>2018-03-01 22:20:35</td>\n",
       "      <td>wechat</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>4.0</td>\n",
       "      <td>22.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1.0</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 25 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "       sku_ID     user_ID         request_time channel    order_ID  \\\n",
       "0  a234e08c57  4c3d6d10c2  2018-03-01 23:57:53  wechat         NaN   \n",
       "1  6449e1fd87           -  2018-03-01 16:13:48  wechat         NaN   \n",
       "2  09b70fcd83  2791ec4485  2018-03-01 22:10:51  wechat  e4874e2a00   \n",
       "3  09b70fcd83  eb0718c1c9  2018-03-01 16:34:08  wechat         NaN   \n",
       "4  09b70fcd83  59f84cf342  2018-03-01 22:20:35  wechat         NaN   \n",
       "\n",
       "   order_date           order_time  quantity  type promise  ...  \\\n",
       "0         NaN                  NaN       NaN   NaN     NaN  ...   \n",
       "1         NaN                  NaN       NaN   NaN     NaN  ...   \n",
       "2  2018-03-01  2018-03-01 14:08:33       1.0   2.0       -  ...   \n",
       "3         NaN                  NaN       NaN   NaN     NaN  ...   \n",
       "4         NaN                  NaN       NaN   NaN     NaN  ...   \n",
       "\n",
       "   coupon_discount_per_unit  gift_item  dc_ori  dc_des  click_week  \\\n",
       "0                       NaN        NaN     NaN     NaN         4.0   \n",
       "1                       NaN        NaN     NaN     NaN         4.0   \n",
       "2                       0.0        0.0    24.0    40.0         4.0   \n",
       "3                       NaN        NaN     NaN     NaN         4.0   \n",
       "4                       NaN        NaN     NaN     NaN         4.0   \n",
       "\n",
       "   click_hour  order_week  order_hour  click_day  order_day  \n",
       "0        23.0         NaN         NaN        1.0        NaN  \n",
       "1        16.0         NaN         NaN        1.0        NaN  \n",
       "2        22.0         4.0        14.0        1.0        1.0  \n",
       "3        16.0         NaN         NaN        1.0        NaN  \n",
       "4        22.0         NaN         NaN        1.0        NaN  \n",
       "\n",
       "[5 rows x 25 columns]"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "clor.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "ed6258d8399da140",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-03-14T13:41:21.073023200Z",
     "start_time": "2024-03-14T13:40:03.943015600Z"
    },
    "collapsed": false,
    "jupyter": {
     "outputs_hidden": false
    }
   },
   "outputs": [],
   "source": [
    "clor.to_csv('CL_OR.csv', index=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "90d7c1122d7e0248",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-03-14T13:41:51.521228400Z",
     "start_time": "2024-03-14T13:41:51.484168300Z"
    },
    "collapsed": false,
    "jupyter": {
     "outputs_hidden": false
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "RangeIndex: 20321457 entries, 0 to 20321456\n",
      "Data columns (total 25 columns):\n",
      " #   Column                      Dtype  \n",
      "---  ------                      -----  \n",
      " 0   sku_ID                      object \n",
      " 1   user_ID                     object \n",
      " 2   request_time                object \n",
      " 3   channel                     object \n",
      " 4   order_ID                    object \n",
      " 5   order_date                  object \n",
      " 6   order_time                  object \n",
      " 7   quantity                    float32\n",
      " 8   type                        float32\n",
      " 9   promise                     object \n",
      " 10  original_unit_price         float32\n",
      " 11  final_unit_price            float32\n",
      " 12  direct_discount_per_unit    float32\n",
      " 13  quantity_discount_per_unit  float32\n",
      " 14  bundle_discount_per_unit    float32\n",
      " 15  coupon_discount_per_unit    float32\n",
      " 16  gift_item                   float32\n",
      " 17  dc_ori                      float32\n",
      " 18  dc_des                      float32\n",
      " 19  click_week                  float32\n",
      " 20  click_hour                  float32\n",
      " 21  order_week                  float32\n",
      " 22  order_hour                  float32\n",
      " 23  click_day                   float32\n",
      " 24  order_day                   float32\n",
      "dtypes: float32(17), object(8)\n",
      "memory usage: 2.5+ GB\n"
     ]
    }
   ],
   "source": [
    "clor.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c19a8bdd3af1c970",
   "metadata": {
    "collapsed": false,
    "jupyter": {
     "outputs_hidden": false
    }
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.19"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
